<?php
/**
 * @version		$Id: comments.php 20196 2011-01-09 02:40:25Z ian $
 * @copyright	Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * je_comment component helper.
 *
 * @package		Joomla.Administrator
 * @subpackage	com_je_comment
 * @since		1.6
 */
class je_commentHelper
{
	/**
	 * Configure the Linkbar.
	 *
	 * @param	string	The name of the active view.
	 *
	 * @return	void
	 * @since	1.6
	 */
	public static function addSubmenu($vName)
	{
		JSubMenuHelper::addEntry(
			JText::_('COM_JE_COMMENT_SUBMENU_COMMENTS'),
			'index.php?option=com_je_comment&view=comments',
			$vName == 'comments'
		);

		JSubMenuHelper::addEntry(
			JText::_('COM_JE_COMMENT_SUBMENU_SETTINGS'),
			'index.php?option=com_je_comment&view=settings',
			$vName == 'settings'
		);

		JSubMenuHelper::addEntry(
			JText::_('COM_JE_COMMENT_SUBMENU_SMILES'),
			'index.php?option=com_je_comment&view=smiles',
			$vName == 'smiles'
		);
	}

	/**
	 * Gets a list of the actions that can be performed.
	 *
	 * @param	int		The category ID.
	 *
	 * @return	JObject
	 * @since	1.6
	 */
	public static function getActions($categoryId = 0)
	{
		$user	= JFactory::getUser();
		$result	= new JObject;

		if (empty($categoryId)) {
			$assetName = 'com_je_comment';
		} else {
			$assetName = 'com_je_comment.category.'.(int) $categoryId;
		}

		$actions = array(
			'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.state', 'core.delete'
		);

		foreach ($actions as $action) {
			$result->set($action,	$user->authorise($action, $assetName));
		}

		return $result;
	}
}
